<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class HotelReferral extends Model
{

    protected $table = 'hotel_referrals';
    protected $guarded = [];

    //一个酒店服务有很多相册图片
    public function gallery()
    {
        return $this->hasMany('App\Model\Gallery','hotel_referral_id');
    }
    //一个酒店服务对应一个分类
    public function category()
    {
        return $this->belongsTo('App\Model\Category','category_id');
    }

    /**
     * 检查是否有子栏目
     */
    static function check_children($id)
    {
        $category = self::with('gallery')->find($id);

        if ($category->gallery->isEmpty()) {
            return true;
        }
        return false;
    }




}
